with open('input.txt') as file:
    ids = set()

    for line in file.readlines():
        row = int(line[:7].replace('F', '0').replace('B', '1'), 2)
        col = int(line[7:].replace('L', '0').replace('R', '1'), 2)

        ids.add(row * 8 + col)

    print(max(ids))